package cn.daniellee.plugin;

import cn.daniellee.plugin.command.BasicCommand;
import cn.daniellee.plugin.command.FilterCommand;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

public class PokeEditFilter extends JavaPlugin {

	public static FileConfiguration config;

	public static String prefix;

	public static PokeEditFilter instance;

	@Override
	public void onEnable() {
		instance = this;

		try {
			Class.forName("com.pixelmonmod.pixelmon.Pixelmon");
		} catch (ClassNotFoundException e) {
			getLogger().info("Can not found the pixelmon mod, plugin will be disabled.");
			return;
		}

		loadConfig();

		getLogger().info(" ");
		getLogger().info(">>>>>>>>>>>>>>>>>>>>>>>> PokeEditFilter Loaded <<<<<<<<<<<<<<<<<<<<<<<<");
		getLogger().info(">>>>> If you encounter any bugs, please contact author's QQ: 768318841 <<<<<");
		getLogger().info(" ");

		Bukkit.getPluginCommand("pokeeditfilter").setExecutor(new BasicCommand());
		Bukkit.getPluginCommand("safepokeedit").setExecutor(new FilterCommand());
	}

	private void loadConfig() {
		getLogger().info("[PokeEditFilter] Loading config...");
		config = getConfig();
		prefix = "&7[&b" + config.get("prompt-prefix") + "&7] &3: &r";
		if(!getDataFolder().exists()) getDataFolder().mkdirs();
		saveDefaultConfig();
	}

	public static PokeEditFilter getInstance() {
		return instance;
	}

	@Override
	public void onDisable() {
		getLogger().info(" ");
		getLogger().info(">>>>>>>>>>>>>>>>>>>>>>>> PokeEditFilter Unloaded <<<<<<<<<<<<<<<<<<<<<<<<");
		getLogger().info(" ");
	}

}
